import time
import unittest
from unit__003.unit_04.Page.Page1 import Page1
from unit__003.unit_04.Page.Page2 import Page2
from unit__003.unit_04.Page.Page import Page
from selenium import webdriver
from unit__003.unit_04.Tools import Tools
from selenium.webdriver.common.by import By



class MyTestCase(unittest.TestCase):
    def setUp(self) -> None:
        print('start case')
        self.driver = webdriver.Edge()
        self.driver.maximize_window()
        Tools().Log()

    def tearDown(self) -> None:
        print('end case')
        time.sleep(5)
        self.driver.quit()


    @unittest.skip
    def test_jiuxian_01(self):
        po1 = Page1(self.driver)
        po1.jiuxian_login()
        time.sleep(5)
        # 删除旧地址 添加新地址
        # 酒仙业务逻辑
        # 1.悬浮-我的酒仙
        po1.xf_move_to()
        time.sleep(2)
        # 2.点击我的订单
        po1.click_myorder()
        time.sleep(2)
        # 窗口切换
        po1.change_window()
        time.sleep(2)
        # 向下滚动
        po1.in_scrollTo()
        time.sleep(2)
        # 3.点击收货地址
        po1.click_address()
        time.sleep(2)
        # 4.点击删除
        po1.click_delete()
        time.sleep(2)
        # 5.点击确定
        po1.click_quedingdz()
        time.sleep(2)
        # 6.再次点击确定
        po1.click_queding2()
        time.sleep(2)
        # 7.输入收货人
        po1.sr_shpeople()
        time.sleep(2)
        # 8.选择省份
        po1.select_province()
        time.sleep(2)
        # 9.选择市
        po1.select_city()
        time.sleep(2)
        # 10.选择区
        po1.select_district()
        time.sleep(2)
        # 11.输入详细地址
        po1.sr_xxdz()
        time.sleep(2)
        # 12.输入编码
        po1.sr_bm()
        time.sleep(2)
        # 13.输入手机号
        po1.sr_sjh()
        time.sleep(2)
        # 14.输入固定电话
        po1.sr_gdphone()
        time.sleep(2)
        # 15.点击提交
        po1.click_conmit()
        time.sleep(2)
        # 16.点击确定
        po1.click_queding3()
        time.sleep(2)

    def test_jiuxian_02(self):
        po2 = Page2(self.driver)
        po2.jiuxian_login()
        time.sleep(2)
        # 1.搜索框输入 五粮液
        po2.search()
        time.sleep(2)
        # 回车事件
        po2.enters()
        time.sleep(2)
        # 窗口切换
        po2.new_window()
        time.sleep(2)
        # 向下滑动 500
        po2.in_scrollTo()
        time.sleep(2)
        # 2.点击商品
        po2.click_sp()
        time.sleep(2)
        # 窗口切换
        po2.new_window()
        # 断言1-  45度 五粮液 五味人生 145ml [兑换]
        dy1 = self.driver.find_element(By.XPATH,'/html/body/div[5]/div[2]/div[2]/div[1]/h1/text()').text
        print('断言1：',dy1)
        self.assertEqual('45度 五粮液 五味人生 145ml [兑换]',dy1)
        time.sleep(2)
        # 断言2-宜宾五粮液生态酿酒有限公司出品
        dy2 = self.driver.find_element(By.XPATH,'/html/body/div[5]/div[2]/div[2]/div[1]/p').text
        print('断言2：',dy2)
        self.assertTrue('宜宾五粮液生态酿酒有限公司出品',dy2)
        # 3.点击加入购物车

    def test_jiuxian_03(self):
        po = Page(self.driver)
        po.jiuxian_login()


if __name__ == '__main__':
    unittest.main()